﻿/******************************************************************
** Copyright (c) 2016 正道远研发中心
** 创建人:  youping
** 创建日期:2018-03-27
** 修改人:
** 修改日期:
** 描 述:  用户表信息
** 版 本:1.0
**-----------------------------------------------------------------
*******************************************************************/

using System;
using System.Collections.Generic;
using System.Data;

namespace PingYou.Demo.BU
{
	using PingYou.Demo.BU.Data;
	using PingYou.Demo.BU.Model;
	using Smart.Core;
	
	[Serializable()]
	public class SYSUserManager : SYSUserData
	{
		public static DataSet Search(DbCon myDbCon, SYSUserQuery QueryData)
		{
			string strQuery = @"SELECT "
			+ SYSUser.ID_FULL + ","
			+ SYSUser.LoginName_FULL + ","
			+ SYSUser.PASSWORD_FULL + ","
			+ SYSUser.UserType_FULL + ","
			+ SYSUser.EmployeeID_FULL + ","
			+ SYSUser.EmpName_FULL + ","
			+ SYSUser.UnitID_FULL + ","
			+ SYSUser.StartDate_FULL + ","
			+ SYSUser.EndDate_FULL + ","
			+ SYSUser.Ip_FULL + ","
			+ SYSUser.Mac_FULL + ","
			+ SYSUser.IsLock_FULL + ","
			+ SYSUser.IsInitialLogin_FULL + ","
			+ SYSUser.NextLoginChange_FULL + ","
			+ SYSUser.UserDesc_FULL + ","
			+ SYSUser.Enabled_FULL + ","
			+ SYSUser.CreateStaff_FULL + ","
			+ SYSUser.CreateDate_FULL + ","
			+ SYSUser.ModifyStaff_FULL + ","
			+ SYSUser.ModifyDate_FULL + ","
			+ " ROW_NUMBER() OVER (ORDER BY "  + QueryData.Sort + ") AS ROWNUM" 
			+ " FROM " + SYSUser.TABLENAME + " WHERE 1 = 1 ";
			
			bool dbCloce = myDbCon == null;
			Dictionary<String, object> myParam = new Dictionary<String, object>();
			
			DataSet myDs = new DataSet();
			try
			{
				myDbCon = DbCon.InitCon(myDbCon);
				if (QueryData.IsPaging)
				{
					myDbCon.FillPage(strQuery, myDs, QueryData.PageIndex, QueryData.PageSize, myParam, SYSUser.TABLENAME);
				}
				else
				{
					myDbCon.Fill(strQuery, myDs, myParam, SYSUser.TABLENAME);
				}
			}
			catch (Exception myEx)
			{
				myEx.Out(string.Format("\r\n SQL:", strQuery));
				throw new Exception(myEx.Message + "\r\n SQL:" + strQuery);
			}
			finally
			{
				myDbCon.Close(dbCloce);
			}
			return myDs;
		}
	}
	
	[Serializable()]
	public class SYSUserQuery
	{
		
		public string Sort = " ID ";
		
		public bool IsPaging = true;
		public int PageIndex = 1;
		public int PageSize = 30;
		public SYSUserQuery()
		{
		}
	}
}
